var status = 0;
var newroom = 0;

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1 || mode == 0) {
		cm.dispose();
	} else {
		status++;
		if (status == 0) {    
			if (cm.getCharQuantity(980000100) > 0) {
				cm.sendSimple("There are " + cm.getCharQuantity(980000100) + " players in #bRoom 1#k\r\n#L1##bTake me there#l\r\n#L2#Nah, i don't like them#k#l");
				newroom = 0;
			} else if (cm.getCharQuantity(980000101) > 0) {
				cm.sendOk("#bRoom 1#k is already in use. Try again later");
				cm.dispose();
			} else {
				cm.sendSimple("Looks like theres nobody in room 1\r\n#L1##bI want to create a room!#l\r\n#L2#I don't feel like creating a room#k#l");
				newroom = 1;
			}
		} else if (status == 1) {
			if (newroom = 0) {
				if (selection == 1) {
					if (cm.getCharQuantity(980000100) == cm.getPartyMembers()) {
						cm.warpParty(980000100);
						cm.dispose();
					} else {
						cm.sendOk("Your party is not a party of " + cm.getCharQuantity(980000100));
						cm.dispose();
					}
				} else {
					cm.sendOk("Goodbye then");
					cm.dispose();
				}
			} else {
				if (selection == 1) {
					cm.warpParty(980000100);
					cm.dispose();
				} else {
					cm.sendOk("Goodbye then");
					cm.dispose();
				}
			}
		}
	}
} 